﻿using Flurl.Http;
using HandyControl.Controls;
using Newtonsoft.Json;
using Reconstruct_Desktop.Apiservice.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Org.BouncyCastle.Math.EC.ECCurve;
using wms_wpf.Apiservice;
using NewWms.Extend;
using AbpApplication.AppServices;

namespace Reconstruct_Desktop.Apiservice;

public class HangFireService_Client : IHangFireService_Client
{
    public async Task<bool> ClosePolling()
    {
        var url = $"http://{GlobalVariable.Config}/api/HangFire/ClosePolling";
        string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostAsync().ReceiveString();
        bool State = JsonConvert.DeserializeObject<bool>(result);
        if (State)
        {
            Growl.Success("停止轮询");
            return true;

        }
        else
        {
            Growl.Warning("操作失败");
            return false;
        }
    }

    public async Task<bool> OpenPolling()
    {
        var url = $"http://{GlobalVariable.Config}/api/HangFire/OpenPolling";
        string result = await url.WithHeader("Authorization", " Bearer" + " " + Jwt.JwtKey).PostAsync().ReceiveString();
        bool State = JsonConvert.DeserializeObject<bool>(result);
        if (State)
        {
            Growl.Success("开始轮询");
            return true;

        }
        else
        {
            Growl.Warning("操作失败");
            return false;
        }
    }
}
